Imports System.ComponentModel

<Description("Enumerator pro kolekce implementujici rozhrani IPoorCollection.")> _
Public Class PoorEnumerator
    Implements IEnumerator

    <Description("Vnitrni kolekce.")> _
    Private m_Collection As IPoorCollection
    <Description("Momentalni pozice v kolekci.")> _
    Private m_CurrentIndex As Integer = 1

    <Description("Konstruktor.")> _
    Public Sub New(<Description("Vnitrni kolekce.")> ByVal collection As IPoorCollection)
        If collection Is Nothing Then Throw New ArgumentNullException("collection")

        Me.m_Collection = collection
    End Sub

    <Description("Vraci polozku na aktualni pozici v kolekci.")> _
    Public ReadOnly Property Current() As Object Implements System.Collections.IEnumerator.Current
        Get
            Return Me.m_Collection.Item(Me.m_CurrentIndex)
        End Get
    End Property

    <Description("Posune se na dalsi pozici v kolekci.")> _
    Public Function MoveNext() As Boolean Implements System.Collections.IEnumerator.MoveNext
        Me.m_CurrentIndex += 1

        If Me.m_CurrentIndex <= Me.m_Collection.Count Then Return True

        Return False
    End Function

    <Description("Resetuje pozici v kolekci.")> _
    Public Sub Reset() Implements System.Collections.IEnumerator.Reset
        Me.m_CurrentIndex = 1
    End Sub
End Class
